import { createSlice } from "@reduxjs/toolkit";

interface UserInfoType {
  userInfo: any;
  token: string;
  shopInfo: any;
}

const initialState: UserInfoType = {
  userInfo: {},
  shopInfo: {},
  token: "",
};

const userInfoSlice = createSlice({
  name: "userInfo",
  initialState,
  reducers: {
    setUserInfo(state, action) {
      state.userInfo = action.payload;
      state.token = action.payload.token;
    },
    setShopInfo(state, action) {
      state.shopInfo = action.payload;
    },
  },
});

export default userInfoSlice.reducer;
export const { setUserInfo, setShopInfo } = userInfoSlice.actions;
